package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface OrderMapper {
    void insert(Orders orders);

    Page<Orders> selectPage(OrdersPageQueryDTO ordersPageQueryDTO);

    Orders selectById(Long id);

    void update(Orders orders);

    @Select("select * from sky_take_out.orders where status=#{status} and order_time<#{orderTime}")
    List<Orders> OrderTimeOut(Integer status, LocalDateTime orderTime);

    @Select("select * from sky_take_out.orders where number=#{orderNumber} and user_id=#{userId}")
    Orders selectByNumberAndByUserID(String orderNumber, Long userId);
    @Select("SELECT count(id) from sky_take_out.orders where status=#{status}" )
    Integer selectStatistics(Integer status);

    List<Long> selectByTime(LocalDateTime beginTime, LocalDateTime endTime);


}
